import axios from 'axios'
import cookie from 'js-cookie'
let instance = axios.create({
    timeOut: 5000,
    headers: {
        'Content-Type': 'application/json' // application/x-www-form-urlencoded
    },
    withCredentials: true
})

instance.interceptors.request.use(config => {
    // if (config.method.toLocaleUpperCase() === 'POST' && config.data) {
    //     config.data = qs.stringify(config.data)
    // }
    config.headers['X-Litemall-Token'] = cookie.get('token') || ''
    return config
}, err => {
    
    console.log(err)
})
instance.interceptors.response.use(config => {
    return config.data
})

export default instance